<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 构造函数继承
        function Test1(name,age){
            this.name = name;
            this.age = age;
        }

        Test1.prototype.sayName = function(){
            console.log(this.name);
        }
        Test1.prototype.zdz = 'zdz';

        function Test2(name,age,location){
            Test1.apply(this,[name,age]);
            Test1.call(this,name,age);//当然用call也是可以的
            this.location = location;
        }

        // 原型继承
        Test2.prototype = Test1.prototype;
        Test2.prototype.constructor = Test2;

        let test2 = new Test2('hzj',20,'苏州张家港');
        console.log(test2);
    </script>
</body>

</html>